package dongze.com.ckdj.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import dongze.com.ckdj.R;

/**
 * Created by fanqwz on 2017/12/18.
 */

public class CheckInOperationMartinTireAdapter extends RecyclerView.Adapter<CheckInOperationMartinTireAdapter.ViewHolder> {
    private List<CheckInOperationItemData> data;

    public CheckInOperationMartinTireAdapter(List<CheckInOperationItemData> data, String value) {
        this.data = data;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View root = LayoutInflater.from(parent.getContext()).inflate(R.layout.check_in_operation_martin_tire_item, null);
        ViewHolder v = new ViewHolder(root);
        return v;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        if (data.size() > position && position >= 0) {
            CheckInOperationItemData d = data.get(position);
            holder.textView.setText(d.value);
            Glide.with(holder.imageView.getContext())
                    .load(d.imgUrl)
                    .into(holder.imageView);
        }
    }

    @Override
    public int getItemCount() {
        return data == null ? 0 : data.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        TextView textView;
        RadioGroup radioGroup;

        public ViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.image);
            textView = (TextView) itemView.findViewById(R.id.text);
            radioGroup = (RadioGroup) itemView.findViewById(R.id.radio_group);
        }
    }

    public String getValue() {
        return null;
    }
}
